{extend name='base' /}
{block name='content'}
<body>
<div class="x-body">
    <form class="layui-form" id="AddData">
        <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>规则名字
            </label>
            <div class="layui-input-inline">
                <input type="text"  name="node_title" required="" lay-verify="required"
                       autocomplete="off" value="" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>用来显示菜单名字
            </div>
        </div>
        <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>规则内容
            </label>
            <div class="layui-input-inline">
                <input type="text"  name="node_name" required="" lay-verify="required"
                       autocomplete="off" value="" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>导航可以为空 样式为：'/模块名字/控制器名字/方法名字'，如：'/index/index/index';
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red">*</span>节点类型</label>
            <div class="layui-input-block">
                <input type="radio" name="type" lay-skin="primary" title="导航" value="1" checked>
                <input type="radio" name="type" lay-skin="primary" title="菜单" value="2">
                <input type="radio" name="type" lay-skin="primary" title="方法" value="3">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="L_pass" class="layui-form-label">
                排序号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="L_pass" name="sort" autocomplete="off" class="layui-input" value="1">
            </div>
            <div class="layui-form-mid layui-word-aux">
                数字越大排位越前
            </div>
        </div>
        <div class="layui-form-item">
            <label  class="layui-form-label">
                规则图标
            </label>
            <div class="layui-input-inline">
                <input type="text"  name="icon" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                导航前面的图标，方法和菜单可以忽略。<a href="http://daniuit.gitee.io/x-admin/index.html" target="_blank">图库地址</a>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">权限验证</label>
            <div class="layui-input-block">
                <input type="checkbox" checked="" name="is_auth" lay-skin="switch" lay-filter="switchTest" lay-text="关|开">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label  class="layui-form-label">
                描述
            </label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容"  name="describe" class="layui-textarea"></textarea>
            </div>
        </div>
        {if isset($pid)}
        <input type="hidden" name="pid" value="{$pid}">
        {/if}
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <a  class="layui-btn" href="javascript:nodeAdd();" >
                增加
            </a>
        </div>
    </form>
</div>
<script>
function nodeAdd() {
   $.ajax({
       url:"{:url('role/nodeadd')}",
       type:'post',
       dataType:'json',
       data:$('#AddData').serialize(),
       success:function (res) {
           if (res.code==1){
               layer.msg(res.message,{icon:6});
               setTimeout(function () {
                   x_admin_close();
                   window.parent.location.reload();
               },1000)
           } else{
               layer.msg(res.message,{icon:2,time:1000})
           }
       },
       error:function () {
           layer.msg('出错了，请稍后再试！',{icon:5,time:1000})
       }
   })
}
</script>
</body>
{/block}